#include <stdio.h>

enum DeviceState
{
  OFF,
  ON,
  SLEEP
};

struct Device
{
  int id;
  char name[20];
  enum DeviceState state;
};

int main()
{
  struct Device device1;
  device1.id = 1;
  snprintf(device1.name, sizeof(device1.name), "Device A");
  device1.state = ON;
  printf("Device ID: %d\n", device1.id);
  printf("Device Name: %s\n", device1.name);
  // 使用switch语句输出设备状态
  switch (device1.state)
  {
  case ON:
    printf("Device State: On\n");
    break;
  case OFF:
    printf("Device State: Off\n");
    break;
  case SLEEP:
    printf("Device State: Sleep\n");
    break;
  }

  struct Device device2;
  device2.id = 2;
  snprintf(device2.name, sizeof(device2.name), "Device B");
  device2.state = OFF;
  printf("Device ID: %d\n", device2.id);
  printf("Device Name: %s\n", device2.name);
  // 使用switch语句输出设备状态
  switch (device2.state)
  {
  case ON:
    printf("Device State: On\n");
    break;
  case OFF:
    printf("Device State: Off\n");
    break;
  case SLEEP:
    printf("Device State: Sleep\n");
    break;
  }
  return 0;
}